package io.renren.modules.basic.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.modules.basic.entity.MtCcUnitInfoEntity;
import io.renren.modules.basic.service.MtCcUnitInfoService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-10-14 10:50:53
 */
@RestController
@RequestMapping("generator/mtccunitinfo")
public class MtCcUnitInfoController {
    @Autowired
    private MtCcUnitInfoService mtCcUnitInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:mtccunitinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = mtCcUnitInfoService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{unitId}")
    @RequiresPermissions("generator:mtccunitinfo:info")
    public R info(@PathVariable("unitId") Integer unitId){
		MtCcUnitInfoEntity mtCcUnitInfo = mtCcUnitInfoService.getById(unitId);

        return R.ok().put("mtCcUnitInfo", mtCcUnitInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:mtccunitinfo:save")
    public R save(@RequestBody MtCcUnitInfoEntity mtCcUnitInfo){
		mtCcUnitInfoService.save(mtCcUnitInfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:mtccunitinfo:update")
    public R update(@RequestBody MtCcUnitInfoEntity mtCcUnitInfo){
		mtCcUnitInfoService.updateById(mtCcUnitInfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:mtccunitinfo:delete")
    public R delete(@RequestBody Integer[] unitIds){
		mtCcUnitInfoService.removeByIds(Arrays.asList(unitIds));

        return R.ok();
    }

}
